let app = getApp()
Component({
    properties: {
        orderId:Number,
        pagetitle:String
      }, 
      data:{
        moneySign:'¥'
      },
    lifetimes: {
        attached: function () {
          this.setData({
            globalColor:app.globalData.globalColor
          })
          var that=this
          wx.request({
            url: app.globalData.siteroot,
            data: {
              do:'Staff_getStaffInfo',
              staff_id:wx.getStorageSync('staff_bind_id')
            },
            success: function(res) {
                that.setData({
                  userInfo:res.data.info
                })
            }
          })
          wx.request({
              url: app.globalData.siteroot,
              data: {
                do:'Order_getOrderDetails',
                order_id:that.data.orderId,
              },
              success: function(res) {
                that.setData({
                  orderInfo:res.data.data
                })
              }
            })
            wx.request({
              url: app.globalData.siteroot,
              data: {
                do:'Order_getExpressInfo',
                order_id:that.data.orderId
              },
              success: function(res) {
                 that.setData({
                   info:res.data.info
                 })
              }
            })
       }
      },
    methods: {
      payorder:function(){
        const order_no =this.data.orderInfo.order_no;
        const user_id=wx.getStorageSync('user_id')
        var that=this
        wx.request({
            url: app.globalData.siteroot,
            data: {
              do:'Pay_orderPay',
              order_no:order_no,
              order_type:0,
              user_id:user_id
            },
            success: function(res) {
                wx.requestPayment({
                    timeStamp: res.data.info.timeStamp,
                    nonceStr: res.data.info.nonceStr,
                    package: res.data.info.package,
                    signType: res.data.info.signType,
                    paySign: res.data.info.paySign,
                    success(res1) {
                       console.log('支付成功')
                    },
                    fail(res1) {
                        console.log('支付失败')
                    }
                  })
            }
          })
      },
      copy:function(){
        var express_no=this.data.info.express_no
        wx.setClipboardData({
          data:express_no,
          success: function (res) {
            wx.getClipboardData({
              success: function (res) {
                wx.showToast({
                  title: '复制成功'
                })
              }
            })
          }
      })
      },
      contact:function(e){
        wx.navigateTo({
          url: '/yb_shopv2/native/all/index?type=chat'
        })
      },
      btnTelPhone:function(e){
        wx.makePhoneCall({
          phoneNumber:e.currentTarget.dataset.key,
          success:function(){
            console.log('拨打成功')
          },
          fail:function(){
            console.log('拨打失败')
          }
        })
      },
    }
});
